package com.jinlejia.common.weight;


import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jinlejia.oldmodule.R;

/**
 */
public class JLJProgressDialog extends AlertDialog {
    private String tip;
    private Context mContext;
    public JLJProgressDialog(Context context) {
        super(context);
    }
    public JLJProgressDialog(Context context, String tips) {
        super(context);
        this.mContext = context;
        this.tip = tips;
    }
    private boolean canCancel = true;
    public JLJProgressDialog(Context context, String tips, boolean canCancel){
        super(context);
        this.mContext = context;
        this.tip = tips;
        this.canCancel = canCancel;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setCanceledOnTouchOutside(false);
        Window window = this.getWindow();
        // *** 主要就是在这里实现这种效果的.
        // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容
        window.setContentView(R.layout.jlj_layout_dialog_progress);
        window.setGravity(Gravity.CENTER);
        window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        window.setBackgroundDrawable(new ColorDrawable());
        setCanceledOnTouchOutside(canCancel);
//        AVLoadingIndicatorView circleProgressBar = (AVLoadingIndicatorView) findViewById(R.id.id_progress);
        TextView tips = (TextView) findViewById(R.id.id_progress_tips);
        if (!TextUtils.isEmpty(tip)){
            tips.setVisibility(View.VISIBLE);
            tips.setText(tip);
        }else {
            tips.setVisibility(View.GONE);
        }
    }
}
